<?php

namespace App\Exports;

use Illuminate\Database\Eloquent\Builder;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Events\BeforeExport;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Illuminate\Contracts\Support\Responsable;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;

/**
 * 考勤月报导出
 *
 * Date: 2018/7/3
 * @author George
 * @package App\Exports
 */
class AttendanceReportExport implements FromCollection, WithStrictNullComparison, Responsable, WithHeadings, WithMapping, WithColumnFormatting, ShouldAutoSize, WithEvents
{
	use Exportable;

	/**
	 * @var string
	 * Date: 2018/7/3
	 * @author George
	 */
	private $fileName = 'attendance.xlsx';

	/**
	 * AttendanceReportExport constructor.
	 * @param $query
	 */
	public function __construct(Builder $query)
	{
		$this->query = $query;
	}

	/**
	 * 获取数据
	 *
	 * Date: 2018/7/3
	 * @author George
	 * @return \Illuminate\Support\Collection
	 */
	public function collection()
	{
		return $this->query->get();
	}

	public function map($item): array
	{
		return [

		];
	}

	public function columnFormats(): array
	{
		return [];
	}

	/**
	 * 设置表头
	 *
	 * Date: 2018/7/3
	 * @author George
	 * @return array
	 */
	public function headings(): array
	{
		return [

		];
	}

	public function registerEvents(): array
	{
		return [
			BeforeExport::class => function(BeforeExport $event) {

			}
		];
	}
}
